lets_plot.GGBunch¶
-
class
lets_plot.GGBunch¶ Collection of plots created by ggplot function. Use method add_plot() to add plot to ‘bunch’. Each plot can have arbitrary location and size. Use show() to draw all plots in bunch.
Examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14
import numpy as np from lets_plot import * LetsPlot.setup_html() np.random.seed(42) n = 100 x = np.arange(n) y = np.random.normal(size=n) w, h = 200, 150 p = ggplot({'x': x, 'y': y}, aes(x='x', y='y')) + ggsize(w, h) bunch = GGBunch() bunch.add_plot(p + geom_point(), 0, 0) bunch.add_plot(p + geom_histogram(bins=3), w, 0) bunch.add_plot(p + geom_line(), 0, h, 2*w, h) bunch.show()
-
__init__()¶ Initialize self.
-
add_plot(plot_spec: lets_plot.plot.core.PlotSpec, x, y, width=None, height=None)¶ Add plot to ‘bunch’.
- Parameters
plot_spec – Plot specification created by ggplot() function.
x (int) – x-coordinate of plot origin in px.
y (int) – y-coordinate of plot origin in px.
width (int) – Width of plot in px.
height (int) – Height of plot in px.
-
as_dict()¶ Returns the dictionary of all properties of the object with as_dict() applied recursively to all subproperties of FeatureSpec type.
- Returns
Dictionary of properties.
- Return type
dict
Examples
1 2 3 4
from lets_plot import * LetsPlot.setup_html() p = ggplot({'x': [0], 'y': [0]}) + geom_point(aes('x', 'y')) p.as_dict()
{'data': {'x': [0], 'y': [0]}, 'mapping': {'x': None, 'y': None}, 'data_meta': {}, 'kind': 'plot', 'scales': [], 'layers': [{'geom': 'point', 'stat': None, 'data': None, 'mapping': {'x': 'x', 'y': 'y'}, 'position': None, 'show_legend': None, 'sampling': None, 'tooltips': None, 'data_meta': {}, 'map': None, 'map_join': None}]}
-
show()¶ Draw all plots currently in this ‘bunch’.
-
props()¶ Returns the dictionary of all properties of the object in their initial form.
- Returns
Dictionary of properties.
- Return type
dict
Examples
1 2 3 4
from lets_plot import * LetsPlot.setup_html() p = ggplot({'x': [0], 'y': [0]}) + geom_point(aes('x', 'y')) p.props()
{'data': {'x': [0], 'y': [0]}, 'mapping': <lets_plot.plot.core.FeatureSpec at 0x9cd7188>, 'data_meta': {}}
-